home *** CD-ROM | disk | FTP | other *** search
- // file: width.cpp
- // checks source code width for publication
- #define MAXWIDTH 50
- #include <stream.hpp>
- #include <string.h>
-
- main() {
- char line[100], * lp;
- char c;
- int count = 0;
- int width;
- while(cin.good()) {
- lp = line;
- while ( cin.get(c), cin.good() && c != '\n')
- *lp++ = c; // get a whole line
- *lp = 0; // null terminate
- count++; // count the line
- // cout << count << ": " << line << "\n";
- width = strlen(line);
- if ( width > MAXWIDTH) {
- cout << "line " << count << " too wide by "
- << width - MAXWIDTH << " characters\n";
- }
- }}
-